package com.ruoyi.develop.lnZhaobiao.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.utils.StringUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.develop.lnZhaobiao.domain.LnZhaobiao;
import com.ruoyi.develop.lnZhaobiao.service.ILnZhaobiaoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;

/**
 * 招标信息Controller
 * @author lmm
 * @date 2025-07-30
 */
@RestController
@RequestMapping("/lnZhaobiao/lnZhaobiao")
public class LnZhaobiaoController extends BaseController {
    @Autowired
    private ILnZhaobiaoService lnZhaobiaoService;

    /**
     * 查询招标信息列表
     */
    @PreAuthorize("@ss.hasPermi('develop:LnZhaobiao:query')")
    @GetMapping("/list")
    public TableDataInfo list(LnZhaobiao entity) {
        startPage();
        List<LnZhaobiao> list = lnZhaobiaoService.selectList(entity);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('develop:LnZhaobiao:query')")
    @GetMapping("/listZb")
    public TableDataInfo listZb(LnZhaobiao entity) {
        startPage();
        List<LnZhaobiao> list = lnZhaobiaoService.selectListZb(entity);
        return getDataTable(list);
    }
    /**
     * 导出招标信息列表
     */
    @PreAuthorize("@ss.hasPermi('develop:LnZhaobiao:export')")
    @Log(title = "招标信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LnZhaobiao entity) {
        List<LnZhaobiao> list = lnZhaobiaoService.selectList(entity);
        ExcelUtil<LnZhaobiao> util = new ExcelUtil<LnZhaobiao>(LnZhaobiao. class);
        util.exportExcel(response, list, "招标信息数据");
    }

    /**
     * 获取招标信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('develop:LnZhaobiao:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(lnZhaobiaoService.selectById(id));
    }

    /**
     * 新增招标信息
     */
    @PreAuthorize("@ss.hasPermi('develop:LnZhaobiao:add')")
    @Log(title = "招标信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody LnZhaobiao entity) {
        return toAjax(lnZhaobiaoService.insert(entity));
    }

    /**
     * 修改招标信息
     */
    @PreAuthorize("@ss.hasPermi('develop:LnZhaobiao:edit')")
    @Log(title = "招标信息", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody LnZhaobiao entity) {
        return toAjax(lnZhaobiaoService.update(entity));
    }

    /**
     * 删除招标信息
     */
    @PreAuthorize("@ss.hasPermi('develop:LnZhaobiao:remove')")
    @Log(title = "招标信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(lnZhaobiaoService.deleteByIds(ids));
    }


    @Log(title = "订单信息导入数据", businessType = BusinessType.INSERT)
    @PostMapping("/importData")
    public AjaxResult importData(LnZhaobiao entity, MultipartFile file) {
        Map<String, Object> error = new HashMap<>();
        error = lnZhaobiaoService.importData(entity,file);
        error.put("code", 200);
        return AjaxResult.success(error);
    }
}
